Skip to content

fix: getGraphMetrics by using Float64 for multipliers in clickhouse queries#2411

Merged
JivusAyrus merged 1 commit intomainfrom
suvij/eng-8657-fix-getgraphmetrics-errors
Dec 15, 2025
Merged

fix: getGraphMetrics by using Float64 for multipliers in clickhouse queries#2411
JivusAyrus merged 1 commit intomainfrom
suvij/eng-8657-fix-getgraphmetrics-errors

Conversation

@JivusAyrus
Copy link
Copy Markdown
Member

@JivusAyrus JivusAyrus commented Dec 15, 2025

Summary by CodeRabbit

Bug Fixes

  • Improved numeric precision in analytics metrics calculations to provide more accurate data representation for request rate and subgraph metrics reporting.

✏️ Tip: You can customize this high-level summary in your review settings.

Checklist

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 15, 2025

Walkthrough

Updated division multiplier types from UInt32 to Float64 across two analytics repository SQL queries to increase numeric precision during value calculations in metrics retrieval operations.

Changes

Cohort / File(s) Summary
Analytics repositories numeric precision updates
controlplane/src/core/repositories/analytics/MetricsRepository.ts, controlplane/src/core/repositories/analytics/SubgraphMetricsRepository.ts
Modified SQL query multiplier types from UInt32 to Float64 in getRequestRateMetrics/getSubgraphRequestRateMetrics and top5 subquery value calculations for increased precision in division operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Both changes follow an identical pattern (UInt32 → Float64 type conversion)
  • Limited scope with only two files affected
  • No control flow, logic, or signature changes
  • Straightforward type precision updates in SQL query parameter bindings

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the main changes: updating multipliers from UInt32 to Float64 in ClickHouse queries across MetricsRepository and SubgraphMetricsRepository files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
controlplane/src/core/repositories/analytics/MetricsRepository.ts (1)

88-88: LGTM! Correctly fixes integer division truncation.

The change from UInt32 to Float64 ensures floating-point division for accurate metric calculations. With integer division, 100 / 30 would truncate to 3, but with Float64 it correctly computes 3.3333..., which is then properly rounded to 4 decimal places.

Consider applying the same fix to granule divisions:

Similar division operations using {granule:UInt32} exist elsewhere in this file (e.g., lines 157, 578-579) and may suffer from the same integer truncation issue. For consistency and precision, consider updating those as well:

round(sum(TotalRequests) / {granule:Float64}, 4)

Also applies to: 122-122

controlplane/src/core/repositories/analytics/SubgraphMetricsRepository.ts (1)

100-100: LGTM! Correctly mirrors the MetricsRepository fix.

The change from UInt32 to Float64 ensures accurate floating-point division for subgraph metrics, consistent with the fix applied to MetricsRepository.ts.

Consider applying the same fix to granule divisions:

Similar division operations using {granule:UInt32} exist elsewhere in this file (e.g., lines 169, 590-591) and may exhibit the same integer truncation behavior. For consistency and precision, consider updating those as well:

round(sum(TotalRequests) / {granule:Float64}, 4)

Also applies to: 134-134

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 923cd4f and 9b1fd1d.

📒 Files selected for processing (2)
  • controlplane/src/core/repositories/analytics/MetricsRepository.ts (2 hunks)
  • controlplane/src/core/repositories/analytics/SubgraphMetricsRepository.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)

Copy link
Copy Markdown
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.31%. Comparing base (923cd4f) to head (9b1fd1d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##            main    #2411       +/-   ##
==========================================
+ Coverage   1.49%   62.31%   +60.82%     
==========================================
  Files        292      295        +3     
  Lines      46926    41134     -5792     
  Branches     431     4194     +3763     
==========================================
+ Hits         703    25634    +24931     
+ Misses     45940    15480    -30460     
+ Partials     283       20      -263     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JivusAyrus JivusAyrus merged commit e5d9750 into main Dec 15, 2025
12 checks passed
@JivusAyrus JivusAyrus deleted the suvij/eng-8657-fix-getgraphmetrics-errors branch December 15, 2025 12:43
dbinnersley added a commit to dbinnersley/cosmo that referenced this pull request Jan 5, 2026
…ueries (wundergraph#2411)

chore(release): Publish [skip ci]

 - wgc@0.102.5
 - @wundergraph/composition@0.49.0
 - controlplane@0.181.0
 - graphqlmetrics@0.37.0
 - @wundergraph/protographic@0.14.0
 - router@0.273.0
 - @wundergraph/cosmo-shared@0.42.24
 - studio@0.147.0

feat: upgrade NextJS (wundergraph#2410)

chore(release): Publish [skip ci]

 - studio@0.148.0

fix: resolve js-yaml vulnerabilities (wundergraph#2415)

feat: validate session cookie (wundergraph#2406)

Co-authored-by: Milinda Dias <83293842+SkArchon@users.noreply.github.com>
chore(release): Publish [skip ci]

 - wgc@0.102.6
 - controlplane@0.182.0
 - keycloak@0.11.1

fix: codecov carryforward paths are not detected (wundergraph#2412)

chore: bumping expr dependency (wundergraph#2419)

fix: make error accessible to custom modules (wundergraph#2420)

chore(release): Publish [skip ci]

 - router@0.273.1

fix: use the correct cgroup policy to work on most of the systems (wundergraph#2421)

chore(release): Publish [skip ci]

 - router@0.273.2

Add support for per message deflate to websocket connectinos

Merge branch 'main' into per-message-deflate
revert formatting
dbinnersley added a commit to dbinnersley/cosmo that referenced this pull request Jan 5, 2026
…ueries (wundergraph#2411)

chore(release): Publish [skip ci]

 - wgc@0.102.5
 - @wundergraph/composition@0.49.0
 - controlplane@0.181.0
 - graphqlmetrics@0.37.0
 - @wundergraph/protographic@0.14.0
 - router@0.273.0
 - @wundergraph/cosmo-shared@0.42.24
 - studio@0.147.0

feat: upgrade NextJS (wundergraph#2410)

chore(release): Publish [skip ci]

 - studio@0.148.0

fix: resolve js-yaml vulnerabilities (wundergraph#2415)

feat: validate session cookie (wundergraph#2406)

Co-authored-by: Milinda Dias <83293842+SkArchon@users.noreply.github.com>
chore(release): Publish [skip ci]

 - wgc@0.102.6
 - controlplane@0.182.0
 - keycloak@0.11.1

fix: codecov carryforward paths are not detected (wundergraph#2412)

chore: bumping expr dependency (wundergraph#2419)

fix: make error accessible to custom modules (wundergraph#2420)

chore(release): Publish [skip ci]

 - router@0.273.1

fix: use the correct cgroup policy to work on most of the systems (wundergraph#2421)

chore(release): Publish [skip ci]

 - router@0.273.2

Add support for per message deflate to websocket connectinos

Merge branch 'main' into per-message-deflate
revert formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants